package com.stone.design.patterns.iterator.employeeiterator.javaiterator;

import com.stone.design.patterns.iterator.employeeiterator.Employee;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @description
 * @Time 2018/4/12 14:17
 * Created by Stone on 2018/4/12.
 */

public class MinIterator implements Iterator {

    private List<Employee> lists = new ArrayList<>();
    private int cursor;
    public MinIterator(List<Employee> lists) {
        this.lists = lists;
    }

    @Override
    public boolean hasNext() {
        return cursor < lists.size();
    }

    @Override
    public Employee next() {
        Employee obj = null;
        if (hasNext()) {
            obj = lists.get(cursor++);
        }
        return obj;
    }

    @Override
    public void remove() {
        if (cursor < 0) {
            throw new IllegalStateException
                    ("you cant remove an item until you've done at least one next");
        }

        if (lists.get(cursor-1) != null) {

        }
    }
}
